<?php
$num = mt_rand();
if ($num % 2 == 0){
    echo "\$num = $num";
    echo "<br>$num 是偶数。";
}

echo "<br />";
$admin = [
    "id" => 1,
    "name" => "admin",
    "roleId" => 1,
    "roleName" => "超级管理员"
];
?>
<form>
    用户id：<?php echo $admin['id']; ?>
    <br/>
    用户名：<input type="text" name="name" value="<?php echo $admin['name']; ?>"/>
    <br/>
    角色组：<select>
        <option id="0">请选择角色组</option>
        <option id="1" <?php if ($admin['roleId'] === 1){echo "selected=\"selected\"";} ?>>超级管理员</option>
        <option id="2" <?php if ($admin['roleId'] === 2){echo "selected=\"selected\"";} ?>>运营组</option>
        <option id="3" <?php if ($admin['roleId'] === 3){echo "selected=\"selected\"";} ?>>产品组</option>
        <option id="4" <?php if ($admin['roleId'] === 4){echo "selected=\"selected\"";} ?>>测试组</option>
        <option id="5" <?php if ($admin['roleId'] === 5){echo "selected=\"selected\"";} ?>>开发组</option>
    </select>
    <br />
    <input type="submit" value="保存" />
    <input type="reset" value="重置" />
</form>
<?php

echo "<br />";
$num = mt_rand(1,31);
if ($num % 2 == 0){
    echo "变量$num 是偶数。";
} else {
    echo "变量$num 为奇数。";
}

echo "<br />";
$month = date("n");
$today = date("j");
if ($today >= 1 and $today <= 10){
    echo "今天是".$month."月".$today."日，是本月上旬";
} else if ($today > 10 and $today <= 20){
    echo "今天是".$month."月".$today."日，是本月中旬";
} else {
    echo "今天是".$month."月".$today."日，是本月下旬";
}

echo "<br />";
$favcolor="red";
switch ($favcolor)
{
    case "red":
        echo "你喜欢的颜色是红色!";
        break;
    case "blue":
        echo "你喜欢的颜色是蓝色!";
        break;
    case "green":
        echo "你喜欢的颜色是绿色!";
        break;
    default:
        echo "你喜欢的颜色不是 红, 蓝, 或绿色!";
}